package com.tjsinfo.tjsoa.worklog.action;

import java.util.Date;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;
import com.tjsinfo.tjsoa.system.vo.User;
import com.tjsinfo.tjsoa.worklog.vo.WorkLogMain;
public class CheckDefalntWorkLogMonthModleDownAction extends WorkLogMonthModleDown {
	private ISystemUserBo userbo;

	public ISystemUserBo getUserbo() {
		return userbo;
	}

	public void setUserbo(ISystemUserBo userbo) {
		this.userbo = userbo;
	}	
	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.worklog.action.WorkLogMonthModleUp#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		Date date = getDate(request);
		User user = getUser(request);
		Map<Integer, WorkLogMain> map = workLogMainBo.selectWorkLogTypeAndYearMAPNumberStart("M", 1900 + date.getYear(), user.getUser_id(), 1);
		TSystemUser tjsuser = getDefinalutTjsuser(request);
		request.setAttribute("tjsuser", tjsuser);
		return forword(mapping, request, date, map);
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.worklog.action.WorkLogMonthModleUp#forword(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest, java.util.Date, java.util.Map)
	 */
	@Override
	protected ActionForward forword(ActionMapping mapping,
			HttpServletRequest request, Date date,
			Map<Integer, WorkLogMain> map) {
		// TODO Auto-generated method stub
		request.setAttribute("userid", Integer.parseInt(request.getParameter("id")));
		return super.forword(mapping, request, date, map);
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.worklog.action.WorkLogMonthModleUp#getUser(javax.servlet.http.HttpServletRequest)
	 */
	@Override
	protected User getUser(HttpServletRequest request) {
		// TODO Auto-generated method stub
		Integer userid = Integer.parseInt(request.getParameter("id"));
		User user = new User();
		user.setUser_id(userid);
		return user;
		
	}
	protected TSystemUser getDefinalutTjsuser(HttpServletRequest request) {
		TSystemUser  tjsuser= userbo.findByIdSystemUser(Integer.parseInt(request.getParameter("id")));
		return tjsuser;
	}
}
